﻿-- =============================================
-- Script Template
-- =============================================




-- fallo TC AP con sumario
select top 15 IdJJ
from tJurisFallo jf
where exists
(
   select 1 
   from tJurisSumarioCaratula jsc
   where jsc.ArchTCompleto = jf.ArchFisico
)
and IdIdentLexis is not null

-- sumario Abeledo Perrot, suelto
select distinct top 15 js.IdJJSumario
from tJurisSumario js
inner join tJurisSumarioCaratula jsc on js.IdJJSumario = jsc.IdJJSumario
where js.IdIdentLexis is not null
and not exists 
(
   select 1
   from tJurisFallo jf
   where jf.ArchFisico = jsc.ArchTCompleto
)
and js.IdBase = 3


-- sumarios oficiales
select distinct top 100 js.IdJJSumario
from tJurisSumario js
inner join tJurisSumarioCaratula jsc on js.IdJJSumario = jsc.IdJJSumario
where js.IdIdentLexis is not null
and not exists 
(
   select 1
   from tJurisFallo jf
   where jf.ArchFisico = jsc.ArchTCompleto
)
and js.IdBase in (4,5)

-- documentos de doctrina
select top 100 IdDDSumario
from tDoctrinaSumario
where IdIdentLexis is not null

GO


